package com.crl.module.loaders.workers
{
	import flash.events.Event;
	import flash.events.HTTPStatusEvent;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;

	public class XMLWorker extends Worker
	{
		public function XMLWorker()
		{
			super();
		}
		
		override public function load(request:URLRequest,autoStart:Boolean=false) : void{
			super.load(request);
			
			loader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, onXMLComplete);
			loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatus);
			loader.addEventListener(IOErrorEvent.IO_ERROR, onIOLoadError);
			loader.addEventListener(IOErrorEvent.DISK_ERROR, onIOLoadError);
			loader.addEventListener(IOErrorEvent.NETWORK_ERROR, onIOLoadError);
			loader.addEventListener(IOErrorEvent.VERIFY_ERROR, onIOLoadError);
			loader.addEventListener(ProgressEvent.PROGRESS, onProgress);
			loader.dataFormat = URLLoaderDataFormat.TEXT;
		}
		
		private function onXMLComplete(event:Event):void{
			this._data = XML(event.target.data);
			super.onComplete(event)
		}
	}
}